package org.yefei.homeworkday14;

public class Circle {
	/*
	 * 2：圆类有半径和圆周率属性，有计算面积和周长方法。 (把圆周率定义成static)
	 */

	private double radius;
	public final static double Pi = 3.14;

	public Circle() {

	}

	public Circle(double radius) {
		this.radius = radius;
	}

	public double getRadius() {
		return radius;
	}

	public void setRadius(double radius) {
		if (radius <= 0) {
			System.err.println("半径不合理，输入值必须大于0");
		}
		this.radius = radius;
	}

	public double calPerimeter() {
		return 2 * Pi * radius;

	}

	public double calArea() {
		return Pi * radius * radius;
}

	public void show() {
		if (radius <= 0) {
			return;
		}
		System.out.println("半径为" + radius + "的圆的周长是：" + calPerimeter());
		System.out.println("半径为" + radius + "的圆的面积是：" + calArea());
	}
}
